package com.zycfc.zsf.boot.util.io;

import com.zycfc.zsf.boot.util.text.StringUtils;
import org.apache.commons.lang3.*;
import java.io.*;
import com.google.common.io.*;
import com.zycfc.zsf.boot.util.text.*;

public abstract class FilePathUtils
{
    public static String getFileName(final String fullName) {
        Validate.notEmpty((CharSequence)fullName);
        final int last = fullName.lastIndexOf(File.separatorChar);
        return fullName.substring(last + 1);
    }
    
    public static String getFileExtension(final File file) {
        return Files.getFileExtension(file.getName());
    }
    
    public static String getFileExtension(final String fullName) {
        return Files.getFileExtension(fullName);
    }
    
    public static String simplifyPath(final String pathName) {
        return Files.simplifyPath(pathName);
    }
    
    public static String contact(final String baseName, final String... appendName) {
        if (appendName.length == 0) {
            return baseName;
        }
        String contactName;
        if (StringUtils.endWith(baseName, File.separatorChar)) {
            contactName = baseName + appendName[0];
        }
        else {
            contactName = baseName + File.separatorChar + appendName[0];
        }
        if (appendName.length > 1) {
            for (int i = 1; i < appendName.length; ++i) {
                contactName = contactName + File.separatorChar + appendName[i];
            }
        }
        return contactName;
    }
}
